home *** CD-ROM | disk | FTP | other *** search
- /*{{{}}}*/
- /*{{{ includes*/
- #include <stdio.h>
- #include <unistd.h>
- #include <stdlib.h>
- #include <string.h>
- #include <ctype.h>
-
- #include <h/keys.h>
- #include <h/token.h>
- #include <h/rcformat.h>
- #include <lib/ori_rc_lib.h>
- #include <lib/ori_add_lib.h>
- /*}}} */
-
- /*{{{ variables*/
- static int ref_word_count=0;
- static char *ref_word_list=0;
- /*}}} */
-
- /*{{{ ref_uncompress_text*/
- void ref_uncompress_text(char const *source,char *dest)
- { char const *ubp;
- char *b;
-
- if (ref_word_list)
- for (ubp=source,b=dest;;)
- { char c;
-
- switch((c = *ubp++))
- { int l;
-
- /*{{{ special coded word*/
- case REF_CODE_LWORD:
- case REF_CODE_UWORD:
- { int id;
-
- id=((unsigned char)*ubp++)-REF_COUNT_BASE;
- /*{{{ append word*/
- if (id<ref_word_count && ref_word_list)
- { char *w;
-
- for (w=ref_word_list;id>0;id--)
- while (*w++);
- if (c==REF_CODE_UWORD)
- { char c;
-
- c= *w++;
- *b++=toupper(c);
- }
- while ((*b = *w++))
- b++;
- }
- else
- *b='\0';
- /*}}} */
- continue;
- }
- /*}}} */
- /*{{{ space sequence*/
- case REF_CODE_SPACES:
- c=' ';
- goto seq_gen;
- /*}}} */
- /*{{{ char sequence*/
- case REF_CODE_CHARS:
- c = *ubp++;
- goto seq_gen;
- /*}}} */
- /*{{{ ctrl*/
- case REF_CODE_C:
- *b++='C';
- *b++='-';
- continue;
- /*}}} */
- /*{{{ meta*/
- case REF_CODE_M:
- *b++='M';
- *b++='-';
- continue;
- /*}}} */
- /*{{{ single char*/
- default:
- l=1;
- goto seq_loop;
- /*}}} */
- /*{{{ decode the sequences*/
- seq_gen:
- l = *ubp++-REF_COUNT_BASE;
- goto seq_loop;
- seq_loop:
- for (;l-->0;*b++=c);
- continue;
- /*}}} */
- /*{{{ 0=eol*/
- case '\0':
- *b='\0';
- break;
- /*}}} */
- }
- break;
- }
- }
- /*}}} */
- /*{{{ ref_free_comp_data*/
- void ref_free_comp_data(void)
- {
- if (ref_word_list)
- { ORIfree(ref_word_list);
- ref_word_list=0;
- ref_word_count=0;
- }
- }
- /*}}} */
- /*{{{ ref_read_comp_data*/
- char *ref_read_comp_data(FILE * const f)
- {
- int l;
- char *s;
-
- ref_free_comp_data();
- if ((l=rc_get_w(f)))
- if ((ref_word_list=ORImalloc(l+1)))
- /*{{{ read all patterns*/
- { rc_nget_c(f,l,ref_word_list);
- for (s=ref_word_list;;)
- if (--l==0)
- /*{{{ list handled, so break*/
- {
- if (*s!='\0')
- ref_free_comp_data();
- else
- ref_word_count++;
- break;
- }
- /*}}} */
- else if (*s++=='\0')
- /*{{{ count the word*/
- ref_word_count++;
- /*}}} */
- s[1]='\0';
- }
- /*}}} */
- else
- rc_skip_cw(f,l,0);
-
- return(ref_word_list);
- }
- /*}}} */
-